package org.stimuliband.dsp.goertzel;

public class HammingWindow {

    final double[] hamming;

    public HammingWindow(int size) {
        hamming = new double[size];
        double o = 2 * Math.PI / size;
        for (int i = 0; i < size; i++) {
            hamming[i] = (0.54 - 0.46 * Math.cos(o * i));
        }
    }

    public double[] filter(double[] signal) {
        double[] result = new double[signal.length];
        for (int i = 0; i < signal.length; i++) {
            result[i] = signal[i] * hamming[i];
        }
        return result;
    }
}
